import {test, expect} from '@playwright/test';
import path from 'path';

test('test upload multiple files at the same time', async ({page}) => {
  await page.goto('/components/uploader/e2e/uploader_multiple_app');
  const fileChooserPromise = page.waitForEvent('filechooser');

  await page.getByText('Upload Image').click();
  const fileChooser = await fileChooserPromise;
  await fileChooser.setFiles([
    path.join(__dirname, 'mesop_robot1.jpeg'),
    path.join(__dirname, 'mesop_robot2.jpeg'),
  ]);

  await expect(page.getByText('File name: mesop_robot1.jpeg')).toHaveCount(1);
  await expect(page.getByText('File name: mesop_robot2.jpeg')).toHaveCount(1);
  await expect(page.getByText('File size: 30793')).toHaveCount(2);
  await expect(page.getByText('File type: image/jpeg')).toHaveCount(2);
  await expect(
    page.locator(
      `//img[@src=""]`,
    ),
  ).toHaveCount(2);
});
